package bz.yfw.example.s3blazeds.part1.helper
{
	import bz.yfw.example.s3blazeds.part1.view.TopView;
	
	import org.seasar.akabana.yui.framework.ns.viewlogic;
	import org.seasar.akabana.yui.framework.ns.viewpart;
	
	import spark.components.Button;
	import spark.components.Label;
	import spark.components.RadioButton;
	import spark.components.RadioButtonGroup;
	import spark.components.TextInput;
	import spark.components.ViewNavigator;
	
	use namespace viewpart;
	
	public class TopHelper
	{
		public var view:TopView;
		
		viewpart var txtinptText:TextInput;
		viewpart var lblResult:Label;
		viewpart var btnSend:Button;
		
		viewpart var rdoBtnPing:RadioButton;
		viewpart var rdoBtnToroku:RadioButton;
		viewpart var rdoBtnShutoku:RadioButton;
		
		viewpart var rdBtnGrup:RadioButtonGroup;
		
		
		public function get inputText():String {
			return txtinptText.text;
		}
		
		public function get selectedRadioValue():String {
			return rdBtnGrup.selectedValue as String;
		}
		
		public function set result(value:String):void {
			lblResult.text = value;
		}
		
		public function initRadioButton():void {
			if (rdoBtnToroku) {
				rdoBtnPing.group 
					= rdoBtnToroku.group 
					= rdoBtnShutoku.group 
					= rdBtnGrup; 
			}
		}
		
		public function doError(isError:Boolean = true):void {
			if (!isError) {
				txtinptText.errorString = null;
			}
			btnSend.enabled = !isError;
		}
		
		public function changeNormalState():void {
			view.viewlogic::stateNormal();
		}
		
		public function connect():void {
			view.viewlogic::editState("接続中...", false);
		}
		
		public function exitSend(message:String):void {
			view.viewlogic::editState(message, true);
		}
	}
}